import axios from 'axios'


const BASE_API = "http://161.117.83.241:6060/comp/"

axios.defaults.baseURL = BASE_API

// 新增背景
export const addBackground = params => {
    return axios.post('background/add', params)
    .then(res => res.data)
}

// 背景上传
export const backgroundUpload = params => {
    return axios.post('background/upload', params)
    .then(res => res.data)
}

// 获取背景列表
export const getBgList = params => {
    return axios.post('background/list', params)
    .then(res => res.data)
}

// 删除背景
export const deleteBackground = (bgId) => {
    return axios.post(`background/delete/${bgId}`)
    .then(res => res.data)
}

// 编辑背景
export const editBackground = (params, bgId) => {
    return axios.post(`background/edit/${bgId}`, params)
    .then(res => res.data)
}

// 设置启动背景
export const setActiveBg = params => {
    return axios.post('background/setActive', params)
    .then(res => res.data)
}

// 根据bgid获取背景
export const getBackground = params => {
    return axios.post(`background/get/${params}`)
    .then(res => res.data)
}


// 字体相关
// 获取字体列表
export const getFontList = params => {
    return axios.post('font/list', params)
    .then(res => res.data)
}

// 删除字体
export const deleteFont = (fontIds) => {
    return axios.post(`font/delete/${fontIds}`)
    .then(res => res.data)
}

// 设置active字体
export const setActiveFont = params => {
    return axios.post('font/setActive', params)
    .then(res => res.data)
}

// 根据id获取字体
export const getFont = params => {
    return axios.post(`font/get/${params}`)
    .then(res => res.data)
}

// 主题素材库
// 添加主题
export const addTopic = params => {
    return axios.post('theme/add', params)
    .then(res => res.data)
}

// 主题图片上传
export const topicUpload = params => {
    return axios.post('theme/upload', params)
    .then(res => res.data)
}

// 获取主题列表
export const getTopicList = appId => {
    return axios.post(`theme/list/${appId}`)
    .then(res => res.data)
}
// 删除主题
export const deleteTopic = themes => {
    return axios.post(`theme/delete/${themes}`)
    .then(res => res.data)
}

// 编辑主题
export const editTopic = (themeId, params) => {
    return axios.post(`theme/edit/${themeId}`, params)
    .then(res => res.data)
}

// 设置active主题
export const setActiveTopic = (appId, params) => {
    return axios.post(`theme/setActive/${appId}`, params)
    .then(res => res.data)
}

// 根据id获取主题
export const getTheme = params => {
    return axios.post(`theme/get/${params}`)
    .then(res => res.data)
}

// 驾舱形象部分
// 获取驾舱list
export const getFigureList = appId => {
    return  axios.post(`portrait/list/${appId}`)
    .then(res => res.data)
}
// 删除驾舱形象
export const deleteFigure = portraitIds => {
    return axios.post(`portrait/delete/${portraitIds}`)
    .then(res => res.data)
}
// 添加驾舱形象
export const addFigure = params => {
    return axios.post('portrait/add', params)
    .then(res => res.data)
}
// 驾舱形象上传
export const figureUpload = params => {
    return axios.post('portrait/upload', params)
    .then(res => res.data)
}
// 设置active驾舱
export const setActiveFigure = (appId, params) => {
    return axios.post(`portrait/setActive/${appId}`, params)
    .then(res => res.data)
}
// 编辑驾舱
export const editFigure = (portraitId, params) => {
    return axios.post(`portrait/edit/${portraitId}`, params)
    .then(res => res.data)
}

// 根据id获取驾舱形象
export const getPortrait = params => {
    return axios.post(`portrait/get/${params}`)
    .then(res => res.data)
}
